
//中心左侧数据
const deviceTotal = [
  {
    id: 1,
    icon: '#icon-jinggao',
    title: '在线数量',
    num: 283680
  },
  {
    id: 3,
    icon: '#icon-gaojing',
    title: '离线数量',
    num: 3679
  }
]


//中心左侧数据
const warningNow = [
  {
    id: 1,
    icon: '#icon-jinggao',
    title: '总告警数',
    num: 12032
  },
  {
    id: 2,
    icon: '#icon-gaojing',
    title: '累计处理',
    num: 11048
  },
  {
    id: 3,
    icon: '#icon-anquanbangzhu',
    title: '累计紧急处理',
    num: 4895
  },
]


// 中心右侧数据

const warningTotal = [
  {
    id: 1,
    icon: '#icon-jinggao',
    title: '当前告警',
    num: 80
  },
  {
    id: 2,
    icon: '#icon-baojing',
    title: '当前报警',
    num: 10
  },
  {
    id: 3,
    icon: '#icon-anquanbangzhu',
    title: '本月修复',
    num: 150
  },
]

//滚动文字的数据
const warningData = [
  {
    id: 1,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 2,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 3,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-baojing',
    info: '设备8890-2021警告信息，二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 4,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 5,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 6,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
  {
    id: 7,
    datetime: '2023-07-23 19:45:32',
    icon: '#icon-jinggao',
    info: '氧气实测值":0.0,"温度实测值":33.06,"二氧化碳校准值":0.0,"温度校准值":3.0,"氧气校准值":0.0,"二氧化碳实测值":0.09,"湿度实测值":0.0,"湿度校准值":0.0'
  },
]

window.onload = function() {
  let oInfobox = document.getElementById("infoBox"),
    intervalTime = 100, //设置时间间隔，越小速度越快
    flag = null; //设置setInterval定时器





  oInfobox.innerHTML += oInfobox.innerHTML; //复制一份内容，无缝滚动




  const scrollUp = function() {
    oInfobox.scrollTop++;

    if (oInfobox.scrollTop >= oInfobox.offsetHeight) {
      //判断元素的滚动高度大于元素本身的高度时，把滚动高度瞬间拉回
      // infoUl.remove();
      oInfobox.scrollTop = 0;
    }
  };

  const startMove = function() {
    flag = setInterval(scrollUp, intervalTime);
  };

  startMove();

  oInfobox.onmouseover = function() {
    clearInterval(flag);
  };
  oInfobox.onmouseout = function() {
    flag = setInterval(scrollUp, intervalTime);
  };

  //右侧时间显示

  let showTime = document.getElementById("showTime");
  let timeFlag = null;

  const changeTime = function() {
    const now = new Date();
    const text = new Intl.DateTimeFormat("default", {
      dateStyle: "medium",
      timeStyle: "medium",
    }).format(now);
    showTime.innerHTML = text;

    // return text;
  };

  const startTime = function() {
    timeFlag = setInterval(changeTime, 1000);
  };

  window.onunload = function() {
    clearInterval(timeFlag);
  };

  startTime();

  //文字展示
};
